package com.yjhb.android.sbz.activity;

import android.text.Html;
import android.widget.TextView;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yjhb.android.sbz.R;
import com.yjhb.android.sbz.tool.Tool;
import com.yjhb.android.sbz.v2.mvp.presenter.ConfigPresenter;
import com.yjhb.android.sbz.v2.mvp.view.ConfigView;
import com.yjhb.android.sbz.view.VerticalView;
import com.jojo.android.zxlib.base.mvp.BasePresenter;

import org.jetbrains.annotations.Nullable;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * 创建者 zx
 * 创建时间 2020/11/23 9:15
 */
public class PublishTypeActivity extends BaseActivity implements ConfigView {
    private final String TAG = "PublishTypeActivity";
    @BindView(R.id.rule_tv)
    TextView ruleTv;

    private ConfigPresenter configPresenter;

    @Override
    protected BasePresenter initPresenter() {
        return null;
    }

    @Override
    protected boolean isImmerse() {
        return true;
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_publish_type;
    }

    @Override
    protected void initUI() {
        configPresenter = new ConfigPresenter(this);
//        ruleTv.setText("一、请严格遵守《赏帮》悬赏任务发布规定\n" +
//                "二、严禁发布低俗、涉黄、违法内容，否则封号处理\n" +
//                "三、请正确设置发布的项目名称与步骤\n" +
//                "四、同一个项目，不同类型则价格不同\n" +
//                "        (1)下载软件:" + DataConf.CATEGORY_ID_DOWNLOAD + "元起\n" +
//                "        (2)账户注册:" + DataConf.CATEGORY_ID_REGISTER + "元起\n" +
//                "        (3)认证绑卡:" + DataConf.CATEGORY_ID_BIND + "元起\n" +
//                "        (4)电商相关:" + DataConf.CATEGORY_ID_EC + "元起\n" +
//                "        (5)应用试玩:" + DataConf.CATEGORY_ID_APP_APPLY + "元起\n" +
//                "        (6)砍价助力、关注投票、转发内容:" + DataConf.SIMPLE_TASK_PRICE + "元起\n" +
//                "        (7)其他任务:" + DataConf.CATEGORY_ID_OTHER + "元起");
    }

    @Override
    protected void initData() {
        configPresenter.getSysConfig("PublicRule");
    }

    @Override
    protected void regEvent() {

    }

    @OnClick({R.id.download_app_vl, R.id.register_vl, R.id.approve_vl, R.id.eCommerce_vl,
            R.id.follow_vl, R.id.vote_vl, R.id.app_apply_vl, R.id.task_type_forward,
            R.id.other_vl})
    void onClick(VerticalView view) {
        String type = view.getTitleView().getText().toString();
        Tool.startPublishTaskAddModeActivity(this, type);
    }

    @OnClick(R.id.back)
    void back() {
        finish();
    }

    @OnClick(R.id.title_right_tv)
    public void title_right_tv() {
        Tool.showPopupRules(this, findViewById(R.id.title_right_tv));
    }


    @Override
    public void onConfig(JSONObject config) {
        System.out.println(config);
        if (config != null) {
            String rule = config.getString("rule");
            ruleTv.setText(Html.fromHtml(rule));
        }
    }

    @Override
    @Deprecated
    public void onConfig(@Nullable JSONArray config) {

    }

    @Override
    public void onFailure(int code, String msg) {

    }
}
